using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Sanchay
{
    public partial class Form2 : Form
    {
       
        private BackgroundWorker m_bgWorker = new BackgroundWorker();
        public Form2()
        {
           
            InitializeComponent();

        }
       
        private void Form2_Load(object sender, EventArgs e)
        {
          

            //progressBar1.Value = 0;
            m_bgWorker.DoWork += new DoWorkEventHandler(m_bgWorker_DoWork);
            m_bgWorker.ProgressChanged += new ProgressChangedEventHandler(m_bgWorker_ProgressChanged);
            m_bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(m_bgWorker_RunWorkerCompleted);

            m_bgWorker.WorkerReportsProgress = true;
            m_bgWorker.WorkerSupportsCancellation = true;

            m_bgWorker.RunWorkerAsync();
        }
        void m_bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            General objGeneral = new General();

            bool isMailSent = objGeneral.SendEmail("db.mdf", "Sanchay-Database-Backup(" + DateTime.Now + ")", "ganesh.agrawal@sapple.co.in");
            if (isMailSent == true)
            {
                MessageBox.Show("Success");

            }
            else
            {
                MessageBox.Show("Failed");
            }
        }

        void m_bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
           //progressBar1.Value = e.ProgressPercentage;
        }

        void m_bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            bool success = (bool)e.Result;
            if (success)
            {
                MessageBox.Show("Success!");
            }
            else
            {
               
              
                MessageBox.Show("Failure!");
            }
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }
    }
}